//
//  SystemMessageViewModel.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/20.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "SystemMessageViewModel.h"
#import "SystemMessageTableViewCell.h"

@interface SystemMessageViewModel ()<UITableViewDelegate,UITableViewDataSource>
{
    NSArray * imageNameArr;
}
@end

@implementation SystemMessageViewModel

-(instancetype)initWithViewToViewModel:(UITableView *)tableView theSuperView:(UIView *)superView{
    if (self = [super initWithViewToViewModel:tableView theSuperView:superView]) {
        imageNameArr = @[@"icon_dingdan",@"icon_shangpinguanli",@"icon_tongzhi"];
        CGFloat t_height;
        if (iPhoneX) {
            t_height = kHeightProportion_In_iPhoneTriploid(12) + 83;
        }else{
            t_height = kHeightProportion_In_iPhoneTriploid(44) + 49;
        }
        tableView.height = tableView.height - t_height;
        tableView.delegate = self;
        tableView.dataSource = self;
        tableView.mj_footer.hidden = YES;
        tableView.mj_header.hidden = YES;
        tableView.rowHeight = kHeightProportion_In_iPhoneTriploid(100);
        [superView addSubview:tableView];
    }
    return self;
}



#pragma mark -- UITableViewDelegate,UITableViewDataSource>
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    SystemMessageTableViewCell * cell = [SystemMessageTableViewCell cellWithTableView:tableView];
    if (indexPath.row == 1) {
        cell.leftTitStr = @"商品";
    }else if (indexPath.row == 2){
        cell.leftTitStr = @"通知";
    }
    cell.imageNameStr = imageNameArr[indexPath.row];
    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (self.delegate && [self.delegate respondsToSelector:@selector(didSelectRowAtIndexPath:)]) {
        [self.delegate didSelectRowAtIndexPath:indexPath];
    }
}
@end
